/**
 * Orienteering Sport Diary Copyright (C) 2009 OSDiary Team
 *
 * This file is part of Orienteering Sport Diary (OSDiary).
 *
 * OSDiary is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see http://www.gnu.org/licenses/.
 */

package org.data;

import java.sql.Time;
import java.util.Arrays;
import java.util.List;
import org.h2.jaqu.Table;
import static org.h2.jaqu.Define.*;

public class RunRace extends Race implements Table, TableWithId {

    public Integer id;
    public Integer distance;
    public Time duration;
    public Integer average_pulse;
    public Integer max_pulse;
    public Integer min_pulse;
    public Integer climb;
    public String description;

    public RunRace() {
        // public constructor
    }

    public RunRace(Integer id, Integer distance, Time duration, Integer average_pulse, Integer max_pulse, Integer min_pulse, Integer climb, String description) {
        this.id = id;
        this.distance = distance;
        this.duration = duration;
        this.average_pulse = average_pulse;
        this.max_pulse = max_pulse;
        this.min_pulse = min_pulse;
        this.climb = climb;
        this.description = description;
    }

    public void define() {
        tableName("RunRace");
        primaryKey(id);
    }

    // test
    private static RunRace create(Integer id, Integer distance, Time duration, Integer average_pulse, Integer max_pulse, Integer min_pulse, Integer climb, String description) {
        return new RunRace(id, distance, duration, average_pulse, max_pulse, min_pulse, climb, description);
    }

    // test method
    public static List<RunRace> getList() {
        RunRace[] list = new RunRace[]{
            create(1, 11, new Time(12345), 100, 120, 80, 5, "description1"),
            create(2, 15, new Time(54321), 110, 130, 90, 5, "description2")
        };
        return Arrays.asList(list);
    }

    @Override
    public String toString() {
        return id.toString();
    }

    public Integer getId() {
        return id;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getDistance() {
        return distance;
    }

    @Override
    public Time getDuration() {
        return duration;
    }
}
